package tech.aistar.mapper.deamnd;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tech.aistar.entity.Category;

import java.util.List;

/**
 * Created by 豆梦寒 on 2019/9/27.
 */
@Repository
public interface CategoryMapper {

    @Select("select * from category")
    List<Category> findAll();
    /**
     * 根据id查找名称
     * @param id
     */
    @Select("select * from category where id = #{value}")
    Category findNameById(Integer id);

    /**
     * 根据id进行删除
     * @param id
     */
    @Update("update category set status = 1 where id = #{value}")
    void delNameById(Integer id);

    /**
     * 添加
     * @param category
     */
    @Insert("insert into category(name,status) values(#{name},#{status})")
    void addCategory(Category category);

    /**
     *  更改
     * @param
     */
    @Update("update category set name=#{name},status=#{status} where id = #{id}")
    void updateCategory(Category category);
}
